/*
 * @Author: wangming
 * @Date: 2020-09-03 16:33:37
 * @LastEditors: wangming
 * @LastEditTime: 2022-03-04 13:59:27
 * @Description: file content
 */
import myMixin from '@/pageComponents/myMixin';
import vmMixin from '@/pageComponents/vmMixin';
export default {
  mixins: [myMixin, vmMixin],
  methods: {
    def() {
      this.datas = this.value;
    },
  },
  data() {
    return {
      datas: '',
    };
  },
  watch: {
    value: {
      handler: 'def',
      immediate: true,
    },
    datas(v) {
      this.$emit('input', v);
    },
  },
  render(h) {
    const { placeholder, width, maxlength, rows } = this.config.__config;
    if (this.viewInfo) {
      return (
        <div style={{ display: 'inline-block', whiteSpace: 'break-spaces', width: width + '%' }}>
          {this.datas}
        </div>
      );
    } else {
      return (
        <el-input
          disabled={this.disabled}
          showWordLimit
          style={{
            width: width + '%'
          }}
          vModel={this.datas}
          placeholder={placeholder}
          maxlength={maxlength}
          rows={rows}
          type="textarea"
          onBlur={() => this.runEventName('blur')}
          onInput={(v) => this.runEventName('change', { values: v })}
          onFocus={() => this.runEventName('focus')}
          vOn:keyup_native={({ keyCode }) => this.runEventName('keyup', { values: keyCode })}
        />
      );
    }
  }
};
